/**
 * Project: shuyin-sync
 * 
 * File Created at Mar 20, 2012
 * $Id$
 * 
 * Copyright 2008 6677bank.com Croporation Limited.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * 6677bank Company. ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with 6677bank.com.
 */
package com.bank6677.sync.csm.dao;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import com.bank6677.sync.csm.domain.Application;
import com.bank6677.sync.csm.domain.ApplicationExt;
import com.bank6677.sync.csm.domain.ApplicationStatFlow;
import com.bank6677.sync.csm.domain.DropApplication;
import com.bank6677.sync.csm.domain.Reservation;
import com.bank6677.sync.csm.domain.SendInstitutionFlow;
import com.bank6677.sync.csm.domain.UrgeApp;
import com.bank6677.sync.csm.domain.old.LoanApply;

/**
 * 同步申请单接口
 * 
 * @author liyue
 * @version ApplicationDao.java Mar 20, 2012 2:35:28 PM
 */
public interface ApplicationDao {

    /**
     * 查找旧贷款申请数据
     * <p>
     * 每次查询按照limit的条件
     * 
     * @param start 开始的计数
     * @param end 结束的计数
     * @return
     * @throws SQLException
     */
    @Deprecated
    List<LoanApply> findOldApplication(Integer start, Integer end) throws SQLException;

    /**
     * 查找旧贷款申请数据
     * <p>
     * 每次查询按照limit的条件
     * 
     * @param start 开始的计数
     * @param end 结束的计数
     * @return 返回的集合中已经组装为新的实体
     * @throws SQLException
     */
    List<Application> findOldApplication2new(Integer start, Integer end) throws SQLException;
    
    /**
     * 查找旧贷款申请数据
     * <p>
     * 每次查询按照limit的条件及贷款申请修改的日期
     * 
     * @param start
     * @param end
     * @param from
     * @param to
     * @return
     * @throws SQLException
     */
    List<Application> findOldApplication2new(Integer start, Integer end, String from, String to) throws SQLException;
    
    /**
     * 查找旧贷款申请数据
     * <p>
     * 按照申请单号串查询
     * 
     * @param applyId
     * @return
     * @throws SQLException
     */
    List<Application> findOldApplication2new(List<Long> appIds) throws SQLException;

    /**
     * <p>
     * 当前所有的就贷款申请量
     * 
     * @param conditions 
     * @return
     * @throws SQLException
     */
    Integer countOldApplication(Map conditions) throws SQLException;

    /**
     * <p>
     * 根据贷款申请id找到该申请所有的催缴记录
     * 
     * @param applyId
     * @return
     * @throws SQLException
     */
    List<UrgeApp> findOldUrgeByApplyId(Long applyId) throws SQLException;

    /**
     * <p>
     * 根据贷款申请id找到该申请所有的操作记录
     * 
     * @param applyId
     * @return
     * @throws SQLException
     */
    List<ApplicationStatFlow> findOldOptLogsByApplyId(Long applyId) throws SQLException;

    /**
     * <p>
     * 根据贷款申请id找到该申请所有的弃单记录
     * 
     * @param applyId
     * @return
     * @throws SQLException
     */
    List<DropApplication> findOldDropFlowByAppId(Long applyId) throws SQLException;

    /**
     * <p>
     * 根据贷款申请id找到该申请所有的预约记录
     * 
     * @param applyId
     * @return
     * @throws SQLException
     */
    List<Reservation> findOldReservationByAppId(Long applyId) throws SQLException;

    /**
     * <p>
     * 根据贷款申请id找到该申请所有的机构派发记录
     * 
     * @param applyId
     * @return
     * @throws SQLException
     */
    List<SendInstitutionFlow> findOldSendFlowByAppId(Long applyId) throws SQLException;

    /**
     * <p>
     * 根据贷款申请id找到该申请的附加信息
     * 
     * @param applyId
     * @return
     * @throws SQLException
     */
    ApplicationExt findAppExtsByAppId(Long applyId) throws SQLException;

    /**
     * <p>
     * Add new application from old version. Be used in sync.
     * 
     * @param application
     * @throws SQLException
     */
    void saveApplication(Application application) throws SQLException;

    /**
     * <p>
     * Add new application batch method.
     * 
     * @see #saveApplication(Application)
     * @throws SQLException
     */
    void batchSaveApplications(List<Application> applications) throws SQLException;
}
